package com.ruoyi.interview.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.interview.domain.TbInterviewType;
import com.ruoyi.interview.service.ITbInterviewTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 面试类型Controller
 * 
 * @author ruoyi
 * @date 2023-01-29
 */
@RestController
@RequestMapping("/type")
public class TbInterviewTypeController extends BaseController
{
    @Autowired
    private ITbInterviewTypeService tbInterviewTypeService;

    /**
     * 查询面试类型列表
     */
    @RequiresPermissions("interview:type:list")
    @GetMapping("/list")
    public TableDataInfo list(TbInterviewType tbInterviewType)
    {
        startPage();
        List<TbInterviewType> list = tbInterviewTypeService.selectTbInterviewTypeList(tbInterviewType);
        return getDataTable(list);
    }

    /**
     * 导出面试类型列表
     */
    @RequiresPermissions("interview:type:export")
    @Log(title = "面试类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbInterviewType tbInterviewType)
    {
        List<TbInterviewType> list = tbInterviewTypeService.selectTbInterviewTypeList(tbInterviewType);
        ExcelUtil<TbInterviewType> util = new ExcelUtil<TbInterviewType>(TbInterviewType.class);
        util.exportExcel(response, list, "面试类型数据");
    }

    /**
     * 获取面试类型详细信息
     */
    @RequiresPermissions("interview:type:query")
    @GetMapping(value = "/{interviewTypeId}")
    public AjaxResult getInfo(@PathVariable("interviewTypeId") Long interviewTypeId)
    {
        return success(tbInterviewTypeService.selectTbInterviewTypeByInterviewTypeId(interviewTypeId));
    }

    /**
     * 新增面试类型
     */
    @RequiresPermissions("interview:type:add")
    @Log(title = "面试类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbInterviewType tbInterviewType)
    {
        return toAjax(tbInterviewTypeService.insertTbInterviewType(tbInterviewType));
    }

    /**
     * 修改面试类型
     */
    @RequiresPermissions("interview:type:edit")
    @Log(title = "面试类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbInterviewType tbInterviewType)
    {
        return toAjax(tbInterviewTypeService.updateTbInterviewType(tbInterviewType));
    }

    /**
     * 删除面试类型
     */
    @RequiresPermissions("interview:type:remove")
    @Log(title = "面试类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{interviewTypeIds}")
    public AjaxResult remove(@PathVariable Long[] interviewTypeIds)
    {
        return toAjax(tbInterviewTypeService.deleteTbInterviewTypeByInterviewTypeIds(interviewTypeIds));
    }
}
